from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

# 设置django环境
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test.settings')

app = Celery('celery_app')
# 发现任务文件每个app下的task.py
app.autodiscover_tasks()
app.config_from_object('django.conf:settings', namespace='CELERY')  # 使用CELERY_ 作为前缀，在settings中写配置


# import datetime
#
# app.conf.update(
#     CELERYBEAT_SCHEDULE = {
#         'sum-task': {
#             'task': 'app.tasks.add',
#             'schedule':  datetime.timedelta(seconds=1),
#             'args': (5, 6)
#         }
#     }
# )